package pixeleditor.ctrl.impl;

import java.awt.event.ActionEvent;
import java.io.File;
import java.util.List;

import javax.swing.AbstractAction;
import javax.swing.JComboBox;

import common.ctrl.IObserver;
import common.gui.IViewable;
import common.util.FileHandler;

import pixeleditor.core.Board;

@SuppressWarnings("serial")
public class ChooseModeCtrl extends AbstractAction implements IObserver {

	
	public ChooseModeCtrl() {
		String f = File.separator;
		List<String> modes = FileHandler.loadResources(
				"." + f +
				"pixelwaks" + f +
				"pixelwaks" + f +
				"plugins" + f +
				"modes", ".java");
		Board.getInstance().setMode(modes.get(0));
	}
	
	@Override
	public void actionPerformed(ActionEvent arg0) {
		JComboBox mode = (JComboBox) this.getValue("ChooseMode.mode");
		Board.getInstance().setMode(mode.getSelectedItem().toString());
	}

	@Override
	public void addView(IViewable iv) {
	}

}
